<?php
/**
 * The model file of blog module of ZenTaoPHP.
 *
 * The author disclaims copyright to this source code.  In place of
 * a legal notice, here is a blessing:
 * 
 *  May you do good and not evil.
 *  May you find forgiveness for yourself and forgive others.
 *  May you share freely, never taking more than you give.
 */
?>
<?php
class overviewModel extends model
{
	
/**
     * Get 得到网站状态信息
     * 
     * @access public
     * @return array
     */
    public function get_sites_info($pager = null,$where_to=null)
    {
    	$where="1=1";
        if(trim($where_to->key_word)!=''){
    		$where.=" and (a.sites_name like '%".$where_to->key_word."%' or a.main_domain like '%".$where_to->key_word."%' or a.sites_remark like '%".$where_to->key_word."%' or a.pre_v6 like '%".$where_to->key_word."%')";
    	}
        if($where_to->type_id!='all'){
    		$where.=" and a.type_id=".$where_to->type_id;
    	}
    	if($where_to->area_id!='all'){
    		$where.=" and a.area_id=".$where_to->area_id;
    	}
   		if($where_to->unit_id!='all'){
    		$where.=" and a.unit_id=".$where_to->unit_id;
    	}
    	if($where_to->source_status!='all'){
    		$where.=" and a.source_status=".$where_to->source_status;
    	}
    	if($where_to->ipv6_status!='all'){
    		$where.=" and a.ipv6_status=".$where_to->ipv6_status;
    	}
    	$where.=" and a.status=1";
        return $this->dao->select('a.*,b.type_name,c.name as area_name,d.unit_name')->from('sites_info as a')
        			 ->leftJoin('type_info as b')->on('a.type_id=b.type_id')
        			 ->leftJoin('area_info as c')->on('a.area_id=c.id')
        			 ->leftJoin('unit_info as d')->on('a.unit_id=d.unit_id')
        		     ->where($where)->orderBy('a.sites_id asc')->page($pager)->fetchAll();
    }
}
